package gui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

public class License extends JDialog
{


   /**
    * 
    */
   private static final long serialVersionUID = 1L;
   private JTextArea area;
   /**
    * Launch the application.
    */
   private String message = "hello";
   private JScrollPane spane;

   /**
    * Create the dialog.
    */
   public License()
   {
      setBounds(100, 200, 450, 400);
      //      setSize(450, 300);
      setResizable(false);
      getContentPane().setLayout(new BorderLayout());

      {
         setMessage();
         JPanel panel = new JPanel();
         spane = new JScrollPane();
         spane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         spane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

         area = new JTextArea();
         area.setText(message);
         area.setEditable(false);
         spane.getViewport().add(area);
         panel.add(spane);
         getContentPane().add(panel, BorderLayout.CENTER);
      }

      {
         JPanel buttonPane = new JPanel();
         buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
         getContentPane().add(buttonPane, BorderLayout.SOUTH);
         {
            JButton okButton = new JButton("OK");
            okButton.setSize(50, 20);
            okButton.addActionListener(new ActionListener()
            {

               @Override
               public void actionPerformed(ActionEvent e)
               {
                  // TODO Auto-generated method stub
                  dispose();
               }
            });
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
         }
      }
   }
   public void setMessage()
   {
      message =
            "Save Connection Costs (SCC) is free software; you can \n" +
                  "redistribute it and/or modify it under the terms\n" +
                  "of the GNU General Public Licence as published by\n" +
                  "the Free Software Foundation; either version 2 of\n" +
                  "the Licence, or (at your option) any later version.\n" +
                  "\nSCC is distributed in the hope that it will be \n" +
                  "useful, but WITHOUT ANY WARRANTY; without even the \n" +
                  "implied warranty of MERCHANTABILITY or FITNESS FOR \n" +
                  "A PARTICULAR PURPOSE.  \n" +
                  "See the GNU General Public Licence for more details.\n" +
                  "You should have received a copy of the GNU General\n" +
                  "Public Licence along with SCC;";
   }

}
